<?php
elgg_register_event_handler('init', 'system', 'clearlytheme_init');

/*
 * Initialize clearly theme
 */
function clearlytheme_init() {
	/* extend css. */
	elgg_extend_view ( 'css/elgg', 'clearly_theme/css' );
	/* remove elgg logo. */
	elgg_unregister_menu_item ( 'topbar', 'elgg_logo' );
	/* customize menu. */
	elgg_unregister_plugin_hook_handler ( 'prepare', 'menu:site', 'elgg_site_menu_setup' );
	elgg_register_plugin_hook_handler ( 'register', 'menu:topbar', 'clearlytheme_menu_setup' );
	/*
	if (elgg_is_active_plugin('search')) {
		//elgg_extend_view('page/elements/topbar', 'search/search_box');
		elgg_unextend_view('page/elements/header', 'search/search_box');
	
		if (!elgg_is_logged_in()) {
			elgg_unextend_view('page/elements/header', 'search/header');
		}
	}
	*/
}

/*
 * setup menu again.
 */
function clearlytheme_menu_setup($hook, $type, $values) {
	$site_menu = elgg_view_menu('site');
	
	$item = new ElggMenuItem('tools', $site_menu, false);
	
	// the tools menu item should be last in default section
	$item->setPriority(1000);
	
	$values[] = $item;
	
	return $values;
	
}